#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        vector<bool> check(1001, false);
        vector<int> ret;
        for (const auto& n : nums1)
        {
            check[n] = true;
        }
        for (const auto& n : nums2)
        {
            if (check[n] == true)
            {
                ret.push_back(n);
                check[n] = false;
            }
        }
        return ret;
    }
};